<?php 
defined('_JEXEC') or die('Restricted access');

class modSketchupHelper
{
	function getSketchups(&$params)
	{
		$items = $params->get('items', 1);
		
		$db =& JFactory::getDBO();
		$query = "SELECT id, f_name, l_name, p_title, thumb1, finalist FROM #__sketchup WHERE  published = '1' ORDER BY sub_date DESC";
		$db->setQuery( $query, 0, $items );
		$rows = $db->loadObjectList();
		
		return $rows;
	}

	function renderSketchups(&$sketchup, &$params)
	{
		
		$link = JRoute::_("index.php?option=com_sketchup&view=project&id=" . $sketchup->id);
		require(JModuleHelper::getLayoutPath('mod_sketchup', '_sketchup'));
	}
	
	function getRandomSketchups(&$params) 
	{ 
        $items = $params->get('items', 1);	
		$db =& JFactory::getDBO();
		$query = "SELECT id, f_name, l_name, p_title, thumb1, finalist FROM #__sketchup WHERE published = '1' ORDER BY RAND()";
		$db->setQuery( $query, 0, $items );
		$rows = $db->loadObjectList();
		
		return $rows;
	}
	
	function getFinalistSketchups(&$params) 
	{ 
        $items = $params->get('items', 1);	
		$db =& JFactory::getDBO();
		$query = "SELECT id, f_name, l_name, p_title, thumb1, finalist FROM #__sketchup WHERE finalist = '1' ORDER BY p_title ASC";
		$db->setQuery( $query, 0, $items );
		$rows = $db->loadObjectList();
		
		return $rows;
	}

}
 
?>